<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="View.*" %>
<%@ page import="java.util.ArrayList" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/index.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Shopping Cart</title>
</head>
<body>
<div id="cart">

<h3>Shopping Cart</h3>
	
	<% 	ArrayList<OrderItemView> cart = (ArrayList<OrderItemView>) request.getSession().getAttribute("cart");
		if(cart != null){
			%>
			<form action="${pageContext.request.contextPath}/item" method="get">
			<table>
			<%
			for(int i = 0; i < cart.size(); i++){
				OrderItemView order = cart.get(i);
	%>
	<tr>
		<td><a href="/webshop/item?id=<%=order.getItem().getItemId()%>"><%=order.getItem().getName()%></a></td><td><%=order.getAmount()%></td>
	</tr>
	<%		}%>
	<tr>
		<td><input type="submit" value="Check out" /></td>
	</tr>
	</table>
	<input type="hidden" name="hidden" value="checkout" />
	</form>
	<form action="${pageContext.request.contextPath}/item" method="post">
		<input type="submit" value="Clear" />
		<input type="hidden" name="hidden" value="clearCart" />
	</form>
	<%	}else{ %>
			No items in cart
	<%	} %>
	
</div>
</body>
</html>